package com.bdth.weget.business.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.bdth.weget.business.entity.Cars;
import com.bdth.weget.business.entity.LocationHis;
import com.bdth.weget.business.mapper.LocationHisMapper;
import com.bdth.weget.business.service.CarsService;
import com.bdth.weget.business.service.LocationHisService;
import com.bdth.weget.util.DateUtil;
import com.bdth.weget.vo.JT0200;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2019/7/15.
 */
@Service
public class LocationHisServiceImpl extends ServiceImpl<LocationHisMapper, LocationHis> implements LocationHisService {

    @Autowired
    private LocationHisMapper locationHisMapper;

    @Autowired
    private CarsService carsService;

    @Override
    public boolean insert(JT0200 bean) {
        LocationHis locationHis = new LocationHis();
        BeanUtils.copyProperties(bean.getLocation(),locationHis);
        locationHis.setCarid(bean.getCarid());
        locationHis.setAltitude((int)bean.getLocation().getAltitude());
        locationHis.setCourse((int)bean.getLocation().getCourse());
        locationHis.setSimno(bean.getSimno());
        locationHis.setUpdatetime(DateUtil.str2date(bean.getTime(),"yyyy-MM-dd HH:mm:ss"));
        Integer result = locationHisMapper.insert(locationHis);
        if(result == 0)
            return false;
        else
            return true;
    }

    @Override
    public List<LocationHis> list(Date start, Date end, String simno) {
        return null;
    }
}
